﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Audio;

namespace PloobsEngine.Audio
{
    internal class SimpleSoundEffect
    {
        SoundEffect mySoundEffect;
        SoundEffectInstance mySoundEffectInstance;
        
        public SimpleSoundEffect(string name, float volume, float pitch, float pan, bool isLooped)
        {            
            this.mySoundEffect = EngineStuff.CustomContentManager.GetAsset<SoundEffect>(name);
            this.mySoundEffectInstance = mySoundEffect.CreateInstance();
            mySoundEffectInstance.Pan = pan;
            mySoundEffectInstance.Pitch = pitch;
            mySoundEffectInstance.Volume = volume;
            mySoundEffectInstance.IsLooped = isLooped;
        }

        public void forcePlay()
        {
            this.mySoundEffect.Play();
        }
        public void Play()
        {
            
            this.mySoundEffectInstance.Play();
        }
        public void Stop()
        {
            this.mySoundEffectInstance.Stop();

        }

        public void Pause()
        {
            this.mySoundEffectInstance.Pause();
        }

        public void Resume()
        {
            this.mySoundEffectInstance.Resume();
        }

        public SoundState State
        {
            get
            {
                return this.mySoundEffectInstance.State;
            }
        }
     
        public void setVolume(float vol)
        {
            this.mySoundEffectInstance.Volume = vol;
        }
    }
}
